﻿@model ProductItem
<div>
    @using (Html.BeginForm())
    {
        <div class="modal-body">
            <dl class="dl-horizontal">
                <dt style="width: 80px;">名 称：</dt>
                <dd style="margin-left: 80px;">
                    <p>
                        @Html.TextArea("name", Model.Name,2, 40, new { onkeyup = "checkValue(this);" })
                    </p>
                </dd>
                <dt style="width: 80px;">副名称：</dt>
                <dd style="margin-left: 80px;">
                    <p>
                        @Html.TextArea("subname", Model.SubName,2, 40, new { onkeyup = "checkValue(this);" })</p>
                </dd>
            </dl>
        </div>
        <div class="modal-footer">
            <p id="message" class="pull-left color-red">
            </p>
            <a class="btn" href="#" data-dismiss="modal">取 消</a>
            <button type="button" class="btn btn-primary" onclick="submitForm(this.form,@(Model.Id))">
                确 认</button>
        </div>
    }
</div>
<script type="text/javascript">
    function checkValue(obj) {
        var val = $(obj).val();

    }
    function submitForm(form, target) {
        var param = $(form).serialize();
        $.postJSON(form.action, param, function (result) {
            if (result.Status) {
                $("#item-name-" + target).html(result.Data);
                $("#item-name-sub-" + target).html(result.Extra);
                $('#message', form).css('color', 'green').html("更新商品名称成功！");
            }
            else {
                $('#message', form).css('color', 'red').html(result.Message);
            }
        });
    }
</script>
